home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#11 (Aug 86)
/
pascal
/
TML source
/
keytrans.asm
< prev
next >
Wrap
Assembly Source File
|
1986-07-13
|
2KB
|
70 lines
; EXAMPLE ASSEMBLY SUBROUTINE
; key test thing
; VERSION 11 July 1986
; (C) Copyright 1986 MacTutor
INCLUDE MACTRAPS.D
; DECLARE LABELS EXTERNAL
XDEF keyTrans ; required for linker
; =========== system globals =============
Key1Trans equ $29E; { Low Memory Globals }
Key2Trans equ $2A2;
; =========== key translation routine ======
KeyTrans:
; key code (2 bytes) and modifiers (2 bytes) passed
; ascii char code returned (2 bytes)
link a6, #-4
movem.l A0-A1/D0-D2, -(SP)
; get key code from stack into D2
; get modifiers from stack into D1
move.w 8(A6), D1 ;second parameter (modifiers)
move.w 10(A6), D2 ;first parameter (key code)
move.w #9, D0 ;shift count for flags
lsr D0,D1 ;move bits to lower byte
andi #7, D1 ;mask 3 bits to get modify in D1
cmpi #64, D2 ;keycode <64 then key1
BGE key2 ;=>64 then key2
key1:
clr.l D0
LEA showit, A0 ;get return address
move.l A0, -(SP) ;return address to stack
move.l #key1trans, A0 ;global for pointer to key1trans rom routine
move.l (A0), A0 ;get address of key1trans
jmp (A0) ;call subroutine
key2:
subi #64, D2 ;adjust key code
clr.l D0
LEA showit, A0 ;get return address
move.l A0, -(SP) ;return address to stack
move.l #key2trans, A0 ;global for pointer to key2trans rom routine
move.l (A0), A0 ;get address of key1trans
jmp (A0) ;call subroutine
showit:
; return function result from D0
move.w D0, 12(A6) ;pass back function result
movem.l (SP)+, A0-A1/D0-D2
unlk a6
move.l (SP)+, A0 ;get return address
addq.l #4, SP ;remove passed parameters
JMP (A0)
; ------------ END OF PROGRAM ----------------